<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //---------------------------------------------------------------------
        //得出实参里的最大值    arguments 是不知道用户传入多少个实参，得到全部实参
        var myMath = {
            PI: 3.141592653,
            max: function () {
                var max = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] > max) {
                        max = arguments[i]
                    }
                }
                return max;
            },
            //---------------------------------------------------------------------
            min: function () {
                var min = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] < min) {
                        min = arguments[i]
                    }
                }
                return min;
            }
        }
        console.log(myMath.PI);
        console.log(myMath.max(4, 5, 9, 7));
        console.log(myMath.min(4, 5, 9, 7));
        //---------------------------------------------------------------------
        var getMax = {
            Max: function () {
                var Max = arguments[0]
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] > Max) {
                        Max = arguments[i]
                    }
                }
                return Max;
            }

        }
        console.log(getMax.Max(1, 5, 10, 6, 3));
        //---------------------------------------------------------------------
        var getMin = {
            min: function () {
                var min = arguments[0];
                for (var i = 1; i < arguments.length; i++) {
                    if (arguments[i] < min) {
                        min = arguments[i]
                    }
                }
                return min;
            }
        }
        console.log(getMin.min(1, 5, 10, 6, 3));
    </script>
</head>

<body>

</body>

</html>